home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / tbproc.arc / TPRO2.PAS < prev    next >
Pascal/Delphi Source File  |  1985-08-16  |  3KB  |  84 lines

  1.  
  2.  
  3.                    T P R O    N U M B E R    2
  4.  
  5.    The following is a set of procedures that we have been used in
  6. various commercial programs. Feel free to use them for commercial
  7. and noncomercial uses. We claim no responsibility to the outcome of
  8. the use of these procedures. You are using them at your own risk.
  9. Enough of the legalities. If you find these routines useful, we
  10. would greatly appreciate any small donation.
  11.  
  12.  
  13.  
  14.  
  15.                                 Soft-Touch Computers
  16.                                 James Billmeyer
  17.                                 7716 Balboa Blvd, Unit D
  18.                                 Van Nuys, Ca  91406
  19.  
  20.  
  21.  
  22.  
  23.  
  24. (****************************************************************)
  25. (*  The GetValidRec procedure will only get the desired record  *)
  26. (*  if it is not deleted. If the record is deleted then the ok  *)
  27. (*  flag is set to false. The use of the GetValidRec procedure  *)
  28. (*  is the same as the  GetRec  procedure except  the  ok flag  *)
  29. (*  must be tested  before using  the  information returned in  *)
  30. (*  the buffer.                                                 *)
  31. (*                                                              *)
  32. (*      EXAMPLE:                                                *)
  33. (*                                                              *)
  34. (*        GetValidRec(Datf,Record_Number,Information);          *)
  35. (*        if  ok  then                                          *)
  36. (*           begin                                              *)
  37. (*               .                                              *)
  38. (*               .                                              *)
  39. (*               .                                              *)
  40. (*                                                              *)
  41. (*  The GetValidRec procedure is useful for rebuilding indexes  *)
  42. (*  for data files that have deleted recordes.                  *)
  43. (*                                                              *)
  44. (*  Add the GetValidRec procedure to the Toolbox Access.box or  *)
  45. (*  Access3.box files.                                          *)
  46. (*                                                              *)
  47. (****************************************************************)
  48.  
  49.  
  50.  
  51.  
  52.  
  53. procedure GetValidRec(var DatF   : DataFile;
  54.                       var R      : Integer;
  55.                       var Buffer           );
  56. var
  57.    temp_rec,
  58.    firstfree    :  integer;
  59.  
  60. begin
  61.   temp_rec := r;
  62.   firstfree  := datf.firstfree;
  63.   ok := true;
  64.   while  (firstfree <> -1) and ok  do
  65.      begin
  66.         if  r = firstfree  then
  67.            ok := false
  68.         else
  69.            begin
  70.               temp_rec := FirstFree;
  71.               GetRec(DatF,temp_rec,TaRecBuf);
  72.               FirstFree := TaRecBuf.I;
  73.            end;
  74.      end;
  75.   if  ok  then
  76.      begin
  77.         Seek(DatF.F,R);
  78.         BlockRead(DatF.F,Buffer,1);
  79.         IOstatus := IOresult;
  80.         TaIOcheck(DatF,R);
  81.      end;
  82. end;
  83.  
  84.